@extends('admin.master')

@section('css')
    <meta name="csrf-token" content="{{ csrf_token() }}">
    @stop

    @section('page_header')
    <h1 class="page-title">
        <i class="voyager-person"></i>@if (empty($user->id)) 添加用户 @else 编辑用户 @endif
    </h1>
    @stop

    @section('content')
    <div class="page-content container-fluid">
        <div class="row">
            <div class="col-md-12">

                <div class="panel panel-bordered">

                    <div class="panel-heading">
                        <h3 class="panel-title">@if (empty($user->id)) 添加用户 @else 编辑用户 @endif</h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form role="form"
                          action=""
                          method="POST" enctype="multipart/form-data">
                        <!-- PUT Method if we are editing -->
                        @if(isset($dataTypeContent->id))
                            {{ method_field("PUT") }}
                        @endif
                        <!-- CSRF TOKEN -->
                        {{ csrf_field() }}
                        <div class="panel-body">
                            @if (count($errors) > 0)
                                <div class="alert alert-danger">
                                    <ul>
                                        @foreach ($errors->all() as $error)
                                            <li>{{ $error }}</li>
                                        @endforeach
                                    </ul>
                                </div>
                            @endif
                            <div class="form-group">
                                <label for="name">姓名</label>
                                <input type="text" class="form-control" name="name"
                                    placeholder="姓名" id="name"
                                    value="{{ $user->name }}">
                            </div>
                            <div class="form-group">
                                <label for="name">邮箱</label>
                                <input type="text" class="form-control" name="email"
                                       placeholder="邮箱" id="email"
                                       value="{{ $user->email }}">
                            </div>
                            <div class="form-group">
                                <label for="name">手机号</label>
                                <input type="text" class="form-control" name="mobile"
                                       placeholder="手机号" id="mobile"
                                       value="{{ $user->mobile }}">
                            </div>
                            <div class="form-group">
                                <label for="password">密码</label>
                                @if(isset($user->password))
                                    <br>
                                    <small style="color:red;">如果不想修改密码请留空</small>
                                @endif
                                <input type="password" class="form-control" name="password"
                                       placeholder="Password" id="password"
                                       value="">
                            </div>
                            <div class="form-group">
                                <label for="password">Avatar</label>
                                 @if(isset($user->avatar))
                                    <img src="/storage/{{ $user->avatar }}"
                                         style="width:200px; height:auto; clear:both; display:block; padding:2px; border:1px solid #ddd; margin-bottom:10px;">
                                @endif
                                <input type="file" name="avatar">
                            </div>
                            <div class="form-group">
                                <label for="role">User Role</label>
                                <select name="role_id" id="role" class="form-control">
                                </select>
                            </div>
                        </div><!-- panel-body -->
                        <div class="panel-footer">
                            <button type="submit" class="btn btn-primary">Submit</button>
                        </div>
                    </form>
                    <iframe id="form_target" name="form_target" style="display:none"></iframe>
                    <form id="my_form" action="" target="form_target" method="post"
                          enctype="multipart/form-data" style="width:0;height:0;overflow:hidden">
                        <input name="image" id="upload_file" type="file"
                               onchange="$('#my_form').submit();this.value='';">
                        <input type="hidden" name="type_slug" id="type_slug" value="">
                        {{ csrf_field() }}
                    </form>
                </div>
            </div>
        </div>
    </div>
    @stop
    @section('javascript')
    <script>
        $('document').ready(function () {
            $('.toggleswitch').bootstrapToggle();
        });
    </script>
    <script src="/js/tinymce/tinymce.min.js"></script>
    <script src="/js/voyager_tinymce.js"></script>
@stop
